import "./assets/main.css";

import { createApp } from "vue";
import App from "./App.vue";
/**
 * axios
 * pinia
 * sass
 * vue-router
 * naive-ui
 * wangeditor
 */
import naive from "naive-ui";
import { createDiscreteApi } from "naive-ui";
import { createPinia } from "pinia";
import { router } from "./common/router.js";
import axios from "axios";
import { useAdminStore } from "@/store/AdminStore.js";

// 服务端地址
// axios.defaults.baseURL = "http://localhost:8080";
axios.defaults.baseURL = "http://www.tacotues.cn";
// 独立API
const { message, notification, dialog } = createDiscreteApi([
  "message",
  "dialog",
  "notification",
]);



const app = createApp(App);
// 全局注入
app.provide("axios", axios);
app.provide("message", message);
app.provide("notification", notification);
app.provide("dialog", dialog);
app.provide("server_url", axios.defaults.baseURL )

// 插件
app.use(naive);
app.use(createPinia());

// 请求拦截器
const adminStore = useAdminStore();
axios.interceptors.request.use((config) => {
  config.headers.token = adminStore.token;
  return config;
});
app.use(router);
app.mount("#app");
